methods: {
    confirmOrder(orderId) {
        const userRole = uni.getStorageSync('userRole'); // Get the user role from storage
        const role = userRole === 2 ? 2 : 1; // Set role based on user role

        uni.request({
            url: `http://localhost:8080/api/orders/${orderId}/confirm`,
            method: 'POST',
            header: {
                'Authorization': `Bearer ${uni.getStorageSync('token')}`,
                'Content-Type': 'application/json'
            },
            data: {
                role: role // Send the role in the request body
            },
            success: (res) => {
                if (res.data.code === 200) {
                    uni.showToast({
                        title: '确认收货成功',
                        icon: 'success'
                    });
                } else {
                    uni.showToast({
                        title: res.data.message,
                        icon: 'none'
                    });
                }
            },
            fail: (error) => {
                console.error('确认收货失败:', error);
                uni.showToast({
                    title: '确认收货失败',
                    icon: 'none'
                });
            }
        });
    }
} 